package chloroform.gdata.gdocs

import com.google.gdata.client.docs.DocsService
import chloroform.oauth.OAuthAccessTokenAndSecret
import scaladuct.{Ref, Starter}

/**
 */
class DocsServiceStarter extends Starter[Starter[DocsService]] {
  def newInstance(): Starter[DocsService] = phaseInit("yourCompany-YourAppName-v1", null)

  def phaseInit(applicationName: String, @Ref oauth: OAuthAccessTokenAndSecret): Starter[DocsService] = {
    new Starter[DocsService] {
      def newInstance() = {
        val service = new DocsService(applicationName)
        oauth.setCredentials(service);
        service
      }
      def destroy(instance: DocsService) = null
    }
  }

  def destroy(instance: Starter[DocsService]) = null
}